<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    class People {
        constructor(name) {
            this.name = name
        }
        eat() {
            console.log(`${this.name} eat something`)
        }
    }
    class Student extends People {
        constructor(name, number) {
            super(name)
            this.number = number
        }
        sayHi() {
            console.log(`姓名:${this.name} 学号:${this.number}`)
        }
    }
    class Teacher extends People {
        constructor(name, major) {
            super(name)
            this.major = major
        }
        teach() {
            console.log(`${this.name} 教 ${this.major}`)
        }
    }

    const s1 = new Student("夏洛特", 100)
    const t1 = new Teacher("王老师", "语文")
    console.log(s1.name, s1.number)
    s1.eat()
    s1.sayHi()

    console.log(t1.name, t1.major)
    t1.eat()
    t1.teach()
</script>

</html>